import React, { Component } from 'react'
import { Modal, Form, Input, message } from 'antd';
import axios from 'axios';
import EditForm from './EditForm';

export default class Editvedio extends Component {
    editForm = null;//报错
    handleEditUser = () => {
        const { validateFields } = this.editForm.formRef.current;
        // console.log(validateFields);
        validateFields()
            .then((values) => {
                //提交表单

                let oldval = { ...this.props.data };

                this.props.edituser(oldval, values);

                message.info('修改成功')
                this.props.close();
            }).catch(errorInfo => {
                message.error('修改失败！');
            })
    }

    render() {
        return (
            <Modal
                destroyOnClose
                title="修改笑话"
                visible={this.props.visible}
                okText="修改"
                cancelText="取消"
                onCancel={() => { this.props.close() }}
                onOk={this.handleEditUser}
            >
                <EditForm ref={frm => this.editForm = frm} data={this.props.data}></EditForm>
            </Modal>
        )
    }
}
